﻿#ifndef CUSTOMTREEVIEWMODEL_H
#define CUSTOMTREEVIEWMODEL_H

#include <QStandardItemModel>

class CustomTreeViewModel : public QStandardItemModel
{
    Q_OBJECT
public:
    struct fileNodeInfo
    {
        QString name;
        bool bcheck;
        QList<fileNodeInfo> m_childNode;
    };

public:
    explicit CustomTreeViewModel(QObject *parent = nullptr);
    ~CustomTreeViewModel();

    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
    Qt::ItemFlags flags(const QModelIndex &index) const override;

    void setFileData(fileNodeInfo *node);

private:
    void updateCheckState(const QModelIndex &index);
    void addData(fileNodeInfo *data, QStandardItem *parent);
    fileNodeInfo *m_fileNodeinfo;
};

#endif // CUSTOMTREEVIEWMODEL_H
